package com.itcast;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class StudentServlet04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int m = 1000;
        String uri = req.getPathInfo();
        uri  = uri.substring(uri.lastIndexOf("/"));
        if ("/vip".equals(uri)) {
            System.out.println("vip打9折所需价格为："+m*0.9+"元");
        } else if ("/vvip".equals(uri)) {
            System.out.println("vvip打8折所需价格为：" + m * 0.8 + "元");
        } else {
            System.out.println("普通用户不打折，所需价格为："+m+"元");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
